package edu.pku.sei.transformation.editor.controller.commands.node;

import org.eclipse.gef.commands.Command;

import edu.pku.sei.modeler.model.core.MetaPackage;
import edu.pku.sei.transformation.editor.model.ModelType;

public class ModelTypeCreateCommand extends Command {
	private MetaPackage metaModelPkg;
	private ModelType metaModel;

	public ModelTypeCreateCommand(ModelType metaModel, MetaPackage metaModelPkg) {
		this.metaModel = metaModel;
		this.metaModelPkg = metaModelPkg;
	}

	@Override
	public boolean canExecute() {
		if (metaModelPkg == null || metaModel == null)
			return false;
		return super.canExecute();
	}

	@Override
	public void execute() {
		metaModelPkg.getNamedElements().add(metaModel);
	}

	@Override
	public void undo() {
		metaModelPkg.getNamedElements().remove(metaModel);
	}
}
